﻿using Com.JunCaiSoft.AutoMapper;
using Com.JunCaiSoft.ConstructionCashFlow.Entity;
using Com.JunCaiSoft.Law.Dto;
using Com.JunCaiSoft.Law.Entity;
using Com.JunCaiSoft.Law.Model;
using Microsoft.AspNetCore.Builder;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Com.JunCaiSoft.Law
{
    public class LawAutoMapperConfigure
    {
        public static void CreateLawMapper(IApplicationBuilder app)
        {
            var creator = app.UseAutoMapper();

            #region 案件管理映射
            creator.CreateMap<CaseMain, CaseMainView>()
                 .ForMember(dest => dest.CaseProject, opt => opt.Ignore())
                 .ForMember(dest => dest.NoticeData, opt => opt.Ignore());
            creator.CreateMap<CaseMainView, CaseMain>()
                 .ForMember(dest => dest.CaseProject, opt => opt.MapFrom(src => src.CaseProject.Id))
                 .ForMember(dest => dest.ExcuteType, opt => opt.Ignore())
                 .ForMember(dest => dest.ExcuteStatus, opt => opt.Ignore());
            creator.CreateMap<Project, CaseProject>()
                .ForMember(dest => dest.Partment, opt => opt.MapFrom(src => src.Partment.ToString()))
                .ForMember(dest => dest.PartmentLeader, opt => opt.Ignore());
            creator.CreateMap<CaseMainItemDto,CaseMainItem> ()
                 .ForMember(dest => dest.CreateTime, opt => opt.MapFrom(src => src.CreateTime.ToString("yyyy-MM-dd")));
            #endregion
        }
    }
}
